package gupaoedu.threadloadSingleton;

/**
 * gupaoedu.threadloadSingleton
 * linwenjie
 * 2019-06-20
 * ThreadLocal线程 单线程唯一
 */
public class ThreadLoadSingleton {
    private ThreadLoadSingleton(){

    }

    private static final ThreadLocal<ThreadLoadSingleton> threadLocal = new ThreadLocal<ThreadLoadSingleton>(){//匿名内部类写法
        @Override
        protected ThreadLoadSingleton initialValue() {
            return new ThreadLoadSingleton();
        }
    };

    public static ThreadLoadSingleton getInstance(){
        return threadLocal.get();
    }


}
